package com.cheng.frame;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import org.dyno.visual.swing.layouts.GroupLayout;

import com.cheng.main.Main;


public class TicketExPanel extends JPanel{
	private static final long serialVersionUID = 1L;
	private TicketExPanel ticketExPanel;
	private Image image;
	
	public TicketExPanel(){
		ticketExPanel = this;
		ticketExPanel.setBorder(BorderFactory.createTitledBorder(null, "车票示例", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, new Font("SansSerif", Font.BOLD, 12),
				new Color(59, 59, 59)));
		ticketExPanel.setLayout(new GroupLayout());

	}
	
	public TicketExPanel getPanel() {
		if (ticketExPanel == null) {
			ticketExPanel = new TicketExPanel();
		}
		return ticketExPanel;
	}  
  
    @Override  
    public void paintComponent(Graphics g1) {  
        int x = 10;  
        int y = 50;  
        Graphics g = (Graphics) g1;  
        try {  
            // 该方法会将图像加载到内存，从而拿到图像的详细信息。  
        	image = ImageIO.read(Main.class.getResourceAsStream("/huochepiao.jpg"));  
        } catch (IOException e) {  
            e.printStackTrace();  
        }
        if (null == image) {  
            System.out.println("error!!!");  
        }  
        
        g.drawImage(image, x, y, image.getWidth(this), image.getHeight(this),  
                this);  
        g = null;  
    }  
}
